package com.tlgen.controller.dean;

import com.tlgen.model.BasicLabor;
import com.tlgen.model.RespBean;
import com.tlgen.service.BasicLaborService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: tlgen
 * @Discription:
 */
@RestController
@RequestMapping("/dean/basiclabor")
public class BasicLaborController {

    @Autowired
    BasicLaborService BasicLaborService;

    @GetMapping("/")
    public List<BasicLabor> getAllBasicLabors() {
        return BasicLaborService.getAllBasicLabors();
    }

    @PostMapping("/")
    public RespBean addBasicLabor(@RequestBody BasicLabor BasicLabor) {
        if (BasicLaborService.addBasicLabor(BasicLabor) == 1) {
            return RespBean.ok("添加成功!");
        }
        return RespBean.error("添加失败!");
    }

    @PutMapping("/")
    public RespBean updateBasicLabor(@RequestBody BasicLabor BasicLabor) {
        if (BasicLaborService.updateBasicLabor(BasicLabor) == 1) {
            return RespBean.ok("更新成功!");
        }
        return RespBean.error("更新失败!");
    }

    @DeleteMapping("/{id}")
    public RespBean deleteBasicLaborById(@PathVariable Integer id) {
        if (BasicLaborService.deleteBasicLaborById(id) == 1) {
            return RespBean.ok("删除成功!");
        }
        return RespBean.error("删除失败!");
    }

    @DeleteMapping("/")
    public RespBean deleteBasicLaborByIds(Integer[] ids) {
        if (BasicLaborService.deleteBasicLaborByIds(ids) == ids.length) {
            return RespBean.ok("删除成功!");
        }
        return RespBean.error("删除失败!");
    }
}
